layui.define(['form', 'layedit', 'laydate','table','element'], function(exports){ //提示：模块也可以依赖其它模块，如：layui.define('layer', callback);
    var layer = layui.layer;
    var loading = {
        open: function() {
            layer.load(1, {
                shade: [0.1,'#000'] //0.1透明度的白色背景
            });
        },
        close:function(){
            layer.closeAll('loading');
        },
        animLine: function() {
            $("#loading-line").addClass("loading-line");
            window.setTimeout(function(){
                $("#loading-line").removeClass("loading-line");
            },600);
        }
    }

    var oka = {
        page:{},
        loading:loading,
        table:{
            refresh: function(table, row, columns, values) {
                var dom = document.querySelector("[lay-filter="+table+"]");
                var index = 0;
                if(dom != null) {
                    dom = dom.nextSibling;
                    index = dom.getAttribute("lay-filter");
                    index = index.substring(index.indexOf("LAY-table-")+10);
                    dom = dom.querySelectorAll(".layui-table-main .layui-table tr")[row];
                }

                if(dom != null) {
                    for(var i = 0; i < columns.length; i++) {
                        dom.querySelector(".laytable-cell-"+index+"-"+columns[i]).innerHTML = values[i]
                    }
                }
            }
        }
    };
    Date.prototype.format = function (fmt) {
        var o = {
            "M+": this.getMonth() + 1,
            "d+": this.getDate(),
            "H+": this.getHours(),
            "m+": this.getMinutes(),
            "s+": this.getSeconds(),
            "q+": Math.floor((this.getMonth() + 3) / 3),
            "S": this.getMilliseconds()
        };
        var year = this.getFullYear();
        var yearstr = year + '';
        yearstr = yearstr.length >= 4 ? yearstr : '0000'.substr(0, 4 - yearstr.length) + yearstr;

        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (yearstr + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    }
    //alert()
    //alert(new Date().format("yyyy-MM-dd HH:mm:ss"));
    window.oka = oka;
    //输出test接口
    exports('oka', oka);
});
